<template>
	<view class="container param-contents">
		<h5 class="param-title">{{ paramTitle }}</h5>
		<!-- 仓控参数查询 -->
		<view class="bin-card" v-if="type == 1">
			<view class="bin-one" v-for="(one, index) in Number(binNum)" :key="index" :is-shadow="false">
				<view class="bin-border" @click="goStateDetail(index)">{{ index + 1 }}号仓</view>
			</view>
		</view>
		<!-- 检测单元 -->
		<view class="bin-card" v-else-if="type==2">
			<view class="bin-one box-one" v-for="(one,index) in comCabinNum" :key="index" :is-shadow="false">
				<view class="bin-border" @click="goStateDetail(index)">检测单元{{index+1}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import state2js from './state2.js';
	export default {
		mixins: [state2js],
		data() {
			return {
				type: 0, //参数类型
				paramTitle: "", //参数模块名称
				binNum: 0, //仓个数
				currentIndex: null, //当前仓号
				command: null, //命令字
				deviceInfo: {}, //设备信息
				dgMessage: "", //检测状态提示信息
			}
		},
		computed: {
			// 柜控电源数量
			comCabinNum() {
				if (Number(this.binNum) < 16) {
					return 1;
				} else if (Number(this.binNum) >= 16 && Number(this.binNum) < 24) {
					return 2;
				} else {
					return 3;
				}
			},
		},
		onLoad(e) {
			this.deviceInfo = JSON.parse(decodeURIComponent(e.deviceInfo));
			this.type = e.type;
			this.binNum = e.binNum;
			this.detailData();
		},
		methods: {
			goStateDetail(index) {
				uni.navigateTo({
					url: `/pagesA/bluetooth/state2/state2Detail?type=${this.type}&binNum=${this.binNum}&index=${index}&deviceInfo=${encodeURIComponent(JSON.stringify(this.deviceInfo))}`
				})
			},
		},
	}
</script>

<style lang="scss" scoped>
	@import "@/static/css/common.scss";
	@import "../index.scss";

	.param-contents {
		padding: 20rpx;
		background: #ffffff;

		.param-one {
			@include flexLayout(center, flex-start);
			border-bottom: 2rpx solid #e5e5e5;
			font-size: 28rpx;
			color: #333333;
			padding: 10rpx 0;

			text {
				width: 220rpx;
				text-align: right;
				margin-right: 20rpx;
			}
		}

		.operate_btns {
			text-align: center;
			margin: 60rpx 0 20rpx;
		}

		.param-title {
			border-left: 8rpx solid #0081ff;
			padding-left: 12rpx;
			border-radius: 8rpx;
			color: #0081ff;
			font-size: 36rpx;
			font-weight: bold;
			margin: 10rpx 0 40rpx;
		}

		.bin_left {
			margin-bottom: 40rpx;
		}
	}
</style>